package com.liveneo.adapter.base.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.liveneo.adapter.base.service.InvokedZteClientService;
import com.liveneo.adapter.base.support.LogUtils;
import com.liveneo.adapter.webservice.client.zte.video.QueryBySql;
import com.liveneo.adapter.webservice.client.zte.video.QueryBySqlResponse;
import com.liveneo.adapter.webservice.client.zte.video.ZteEbaseAccess;
import com.liveneo.system.base.utils.XmlUtils;

/**
 * 调用“中兴监控和预测数据接口”服务实现类
 * 
 * @author fucy
 *
 */
@Service
public class InvokedZteClientServiceImpl implements InvokedZteClientService {
    @Autowired
    private ZteEbaseAccess zteEbaseAccess;

    /**
     * 查询“中兴监控和预测数据接口”
     */
    @Override
    public QueryBySqlResponse queryBySqlRequest(QueryBySql request) {
        LogUtils.info("[zteEbaseAccess]查询中兴监控和预测数据，传入数据【\n" + XmlUtils.toXml(request) + "\n】");
        QueryBySqlResponse queryBySqlResponse = null;
        try {
            queryBySqlResponse = zteEbaseAccess.queryBySqlRequest(request);
        } catch (Exception e) {
            // 记录日志
            LogUtils.error("[zteEbaseAccess]查询中兴监控和预测数据失败，失败信息【" + e.getMessage() + "】", e);
            throw new RuntimeException(e);
        }
        LogUtils.info("[zteEbaseAccess]查询中兴监控和预测数据，返回数据【\n" + XmlUtils.toXml(queryBySqlResponse) + "\n】");
        return queryBySqlResponse;
    }
}
